package cn.dida.service.impl;

import cn.dida.dao.LgsDepotDao;
import cn.dida.model.LgsDepot;
import cn.dida.model.Pageable;
import cn.dida.service.LgsDepotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by zhangzhiling on 2017/2/8.
 */
@Service
public class LgsDepotServiceImpl implements LgsDepotService{

    @Autowired
    private LgsDepotDao lgsDepotDao;

    @Override
    public Pageable<LgsDepot> getDepotList(Integer companyId, String keyword, Integer sta, Integer page) {
        return lgsDepotDao.query(companyId, keyword, sta, page);
    }

    /**
     * 新增地点
     * @param lgsDepot
     * @return
     */
    @Override
    @Transactional
    public Boolean setDepot(LgsDepot lgsDepot ) {
        Integer depotId = lgsDepotDao.insert(lgsDepot);
        return true;
    }

    /**
     * 编辑地点
     * @param lgsDepot
     * @return
     */
    @Override
    @Transactional
    public Boolean update(LgsDepot lgsDepot) {
        return lgsDepotDao.update(lgsDepot) == 1;
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @Override
    public LgsDepot getLgsDepot(Integer id) {
        return lgsDepotDao.getLgsDepot(id);
    }

    /**
     * 根据状态获取列表
     * @param companyId
     * @param sta
     * @return
     */
    @Override
    public List<LgsDepot> getList(Integer companyId, Integer sta){
        return lgsDepotDao.getList(companyId, sta);
    }

    /**
     * 验证地点名称是否已存在
     * @param companyId
     * @param name
     * @return TRUE：存在； false：不存在
     */
    @Override
    public LgsDepot testName( Integer companyId, String name){
        LgsDepot  lgsDepot=  lgsDepotDao.testName(companyId, name);
        return lgsDepot;
    }
}
